<template>
  <div class="content">
    <dt-search ref="search">
      <Button type="primary" v-if="unlocking('0207010501')" @click="onExport">
        导出
      </Button>
    </dt-search>

    <dt-grid ref="table" page :onFetch="onFetch" />
  </div>
</template>

<script>
  import moment from 'moment'
  import Column from './opt/Column.js'
  import SearchOpt from './opt/SearchOpt.js'
  import confirmMgr from '@/biz/report/commConfirmReport.js'

  export default {
    data() {
      return {
        search: {
          commissionStartMonth: moment(new Date()).format('YYYY-MM'),
          commissionEndMonth: moment(new Date()).format('YYYY-MM')
        }
      }
    },
    mounted() {
      this.$refs.search.init(
        this.$refs.table,
        new SearchOpt(this.search),
        this.search
      )
      this.$refs.table.init(this, new Column())
      this.$refs.table.fetch()
    },
    methods: {
      onFetch(data) {
        this.search = data
        return confirmMgr.list(data)
      },
      onExport() {
        return confirmMgr.exportData(this.search)
      }
    }
  }
</script>

<style lang="scss" scoped>
  .content {
    padding: 20px;
  }
</style>
